package com.welyo.view.quizz.button {
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author vu.doan
	 */
	public class TabButton extends MovieClip {
		
		private var isActive		:Boolean;
		
		public function TabButton() {
			mcHit.buttonMode = true;
			mcHit.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverHandler);
			mcHit.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler);
		}
		
		public function set Active(value:Boolean):void {
			isActive = value;
			
			this.mouseChildren = this.mouseEnabled = !isActive;
			
			if (isActive) {
				gotoAndStop("active");
			} else {
				gotoAndStop("out");
			}
		}
		
		public function set Label(value:String):void {
			txtTitle.text = value;
			txtTitleShadow.text = value;
		}
		
		private function onMouseOverHandler(evt:MouseEvent):void {
			if (isActive) {
				return;
			}
			evt.currentTarget.parent.gotoAndStop("over");
		}
		
		private function onMouseOutHandler(evt:MouseEvent):void {
			if (isActive) {
				return;
			}
			
			evt.currentTarget.parent.gotoAndStop("out");
		}
	}
}